package demoMod.stsconsole.helpers;

import demoMod.stsconsole.dungeons.AbstractDungeon;
import demoMod.stsconsole.relics.AbstractRelic;
import demoMod.stsconsole.relics.BurningBlood;
import demoMod.stsconsole.relics.Circlet;
import demoMod.stsconsole.relics.OddMushroom;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class RelicLibrary {
    private static final Map<String, AbstractRelic> relics = new HashMap<>();
    private static final AbstractRelic circlet = new Circlet();

    public static void initialize() {
        relics.clear();
        relics.put(BurningBlood.ID, new BurningBlood());
        relics.put(OddMushroom.ID, new OddMushroom());
    }

    public static AbstractRelic getRelic(String id) {
        return relics.getOrDefault(id, circlet);
    }

    public static List<AbstractRelic> getCombatRelics() {
        return relics.values().stream().filter(
                relic -> relic.color == AbstractRelic.RelicColor.SHARED ||
                         relic.color == AbstractDungeon.player.getRelicColor()
        ).collect(Collectors.toList());
    }

    public static List<AbstractRelic> getRelicsByRarity(AbstractRelic.RelicRarity rarity) {
        return relics.values().stream().filter(
                relic -> relic.rarity == rarity
        ).collect(Collectors.toList());
    }
}
